package com.fosu.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import com.fosu.utils.NumFormatter;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.util.List;

/**
 * Desription
 * 评论类
 * @author manno
 * @date 2020/10/15
 */
@Data
@Component
public class Comment
{
    /**评论id*/
    private Integer commentId;
    /**商品id*/
    private Integer productId;
    /**发布评论者id*/
    private Integer ownerUserId;
    /**该评论回复评论的id*/
    private Integer targetCommentId;
    /**评论内容*/
    private String content;
    /**评论时间*/
    private Timestamp createTime;
    /**用户头像url*/
    private String avatarUrl;
    /**用户名*/
    private String nickName;
    /**在查询时规范化时间戳格式*/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+0")
    public Timestamp getCreateTime()
    {
        return createTime;
    }
    /**该评论的回复*/
    private List<Comment> replies;
    /**评论被点赞数*/
    @JsonIgnore
    private Integer like;
    /**转换后的点赞数格式*/
    private String likes;
    /**自动转换格式*/
    public void setLike(Integer like)
    {
        this.likes = NumFormatter.formatNum(like);
    }
    /**是否被当前用户点赞*/
    public boolean isFavorite;
}
